package com.fjec.market.rabbitmq.provider;

import org.springframework.amqp.core.Message;
import org.springframework.amqp.core.MessageProperties;
import org.springframework.amqp.rabbit.connection.CorrelationData;
import org.springframework.amqp.rabbit.core.RabbitTemplate;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Component;

import javax.annotation.Resource;

@Component
public class YsRegisterResultQueryProvider {
    @Value("${fjec.market.ysregisterresultquery.exchange.name}")
    private String exchangeName;

    @Value("${fjec.market.ysregisterresultquery.router.key}")
    private String routingKey;

    @Value("${fjec.market.ysregisterresultquery.delay.value}")
    private Integer delay;

    @Resource(name = "ysRegisterResultQueryTemplate")
    private RabbitTemplate ysRegisterResultQueryTemplate;

    public void sendYsRegisterResultQuery(Long regId) {
        MessageProperties props = new MessageProperties();
        props.setHeader("delay", delay * 1000);
        Message msg = new Message(regId.toString().getBytes(), props);
        ysRegisterResultQueryTemplate.convertAndSend(exchangeName, routingKey, msg);
    }
}
